package com.echo.register.commons.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * @program: com.echo.voter
 * @description: 自定义Filter类
 * @author: Xiaoti
 * @create: 2018-11-06 21:48
 **/
public class VoteFilter implements Filter {

    private static Logger logger = LoggerFactory.getLogger(VoteFilter.class);

    @Override
    public void init(FilterConfig filterConfig) throws ServletException{

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException{
        HttpServletRequest httpServletRequest = (HttpServletRequest)request;

//        Cookie cookie = CommonUtils.getCookie(httpServletRequest, VoteSerivce.COOKIE_UM_TOKEN);
//        CookieHolder.add(cookie);
//        if(cookie == null){
//            logger.info("cookieHolder add cookie is null");
//        }else {
//            logger.info("cookieHolder add cookie is {}", cookie.getValue());
//        }

        chain.doFilter(request, response);
    }

    @Override
    public void destroy() {

    }
}
